//
//  CommonMacros.h
//  ACE
//
//  Created by Mickey Yin on 2021/12/1.
//

#ifndef CommonMacros_h
#define CommonMacros_h

#pragma mark ----开发的时候打印，但是发布的时候不打印的NSLog
#ifdef DEBUG
#define NSLog(...) NSLog(@"%s 第%d行 \n %@\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
#else
#define NSLog(...)
#endif


#pragma mark ---- block
typedef void(^JXBankBlock)(BOOL jxbankBlock);


#pragma mark ----weak 强弱引用
#define kWeakSelf(type)  __weak typeof(type) weak##type = type;
#define kStrongSelf(type) __strong typeof(type) type = weak##type;


#pragma mark ---- 字符串是否为空
#define kStringIsEmpty(string) ((![string isKindOfClass:[NSString class]])||[string isEqualToString:@""] || (string == nil) || [string isEqualToString:@""] || [string isKindOfClass:[NSNull class]]||[[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0)

#pragma mark --数组是否为空
#define kArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)

#pragma mark --数组是否为空
#define kDictIsEmpty(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys == 0)


#pragma mark --是否空对象
#define kObjectIsEmpty(_object) (_object == nil \
                                || [_object isKindOfClass:[NSNull class]] \
                                || ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
                                || ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))

#pragma mark --常用的缩写
//APP对象 （单例对象）
#define kApplication [UIApplication sharedApplication]
//主窗口 （keyWindow）
#define kKeyWindow [UIApplication sharedApplication].keyWindow
//APP对象的delegate
#define kAppDelegate [UIApplication sharedApplication].delegate
//NSUserDefaults实例化
#define kUserDefaults [NSUserDefaults standardUserDefaults]
//通知中心 （单例对象）
#define kNotificationCenter [NSNotificationCenter defaultCenter]

#pragma mark --APP版本号1.0.0
#define AppVersion  [[[NSBundle mainBundle] infoDictionary] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]
#pragma mark --系统版本号
#define KSystemVersion  [[[UIDevice currentDevice] systemVersion] floatValue]
#pragma mark --APPbuild版本号
#define APPBuildVersion  [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
#pragma mark --获取应用名称
#define APP_NAME  [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]
#pragma mark --获取当前语言
#define kCurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])

#pragma mark --获取沙盒的Document路径
#define kDocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]

#pragma mark --获取沙盒的temp路径
#define kTempPath NSTemporaryDirectory()

#pragma mark --获取沙盒的Cache路径
#define kCachePath [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]

#pragma mark --由角度转换为弧度
#define kDegreesToRadian(x) (M_PI * (x) / 180.0)

#pragma mark --由弧度转换为角度
#define kRadianToDegrees(radian) (radian * 180.0) / (M_PI)

#pragma mark --获取一段时间间隔
#define kStartTime CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
#define kEndTime  NSLog(@"Time: %f", CFAbsoluteTimeGetCurrent() - start)

#pragma mark --设置 控件 边框角标，宽度，颜色
#define ViewBorderRadius(View, Radius, Width, Color)\\
                            [View.layer setCornerRadius:(Radius)];\
                            [View.layer setBorderWidth:(Width)];\
                            [View.layer setBorderColor:[Color CGColor]]

#pragma mark -- 设置 控件 角标
#define ViewRadius(View,Radius)\\
                      [View.layer setCornerRadius:(Radius)];\
                      [View.layer setMasksToBounds:YES]

//设置坐标
#define BMCGRect(x, y, w, h) CGRectMake(x, y, w, h)

//设置角标
#define TabbarBedge(index,x)\\
                        UITabBarItem * item=[self.tabBarController.tabBar.items objectAtIndex:index];\
                        item.badgeValue=[NSString stringWithFormat:x]

//清空角标
#define CleanTabbarBedge(index)\\
                            UITabBarItem * tabItem=[self.tabBarController.tabBar.items objectAtIndex:index];\
                            tabItem.badgeValue = nil

// 获取本地图片进行加载
#define ImageNamed(fileName) [UIImage imageNamed:fileName]

#pragma mark --导航栏图片
#define navbar_whiteBg (kIs_iPhoneX ? @"navbar_whiteBg_X" : @"navbar_whiteBg")

#pragma mark --手机唯一标识
#define KEY_USERNAME_PASSWORD    @"com.company.yinapp.usernamepassword"
#define KEY_USERNAME             @"com.company.yinapp.username"
#define KEY_PASSWORD             @"com.company.yinapp.password"

#pragma mark --APP版本号
#define hash @"dfknfdkfldfddkjfldf"

//微信登录、分享
#define kUmengappKey             @"78dbd96c678e0f9bb492bc4fgf2a" //友盟appkey
#define kwx_Appid                @"wx2103783052fda1vc7e9c" //微信appkey
#define kwx_AppSecret            @"36d5300drhjjj709cf3e0004180a20hjdwb" //微信AppSecret
#define kwx_Universallink        @"https://cmpmappobile.bomjq.com/"  //微信Universallink

#endif /* CommonMacros_h */
